class Solution {
public:
    string compressString(string s) {
        string ans;
        int n = s.size();
        for (int i = 0; i < n; i++) {
            int j = i + 1;
            while (j < n && s[j] == s[i])j++;
            ans.push_back(s[i]);
            int k = j - i;
            string temp;
            while (k) {
                int x = k % 10;
                temp += (char)x + '0';
                k /= 10;
            }
            reverse(temp.begin(), temp.end());
            //cout<<"temp=="<<temp<<endl;
            ans += temp;
            i = j - 1;
        }
        cout << "ans==" << ans << endl;
        if (ans.size() >= n)ans = s;
        return ans;
    }
};